package com.bw.module_home.visit.adapter

import android.graphics.Color
import android.widget.ImageView
import android.widget.TextView
import com.bw.module_home.R
import com.bw.module_home.visit.model.VisitEntityItem
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class VisitAdapter: BaseQuickAdapter<VisitEntityItem, BaseViewHolder>(
    R.layout.item_visit
) {
    override fun convert(holder: BaseViewHolder, item: VisitEntityItem) {
        val time = holder.getView<TextView>(R.id.visit_time)
        val status = holder.getView<TextView>(R.id.visit_status)
        val name = holder.getView<TextView>(R.id.visit_name)
        val phone = holder.getView<TextView>(R.id.visit_phone_num)
        val purpose = holder.getView<TextView>(R.id.visit_purpose)
        val employ = holder.getView<TextView>(R.id.visit_employeeId)
        time.text = item.appointmentTime
        name.text = item.visitorName
        phone.text = item.phoneNumber
        purpose.text = "来访事由：${item.purpose}"
        employ.text = "来访人ID：${item.employeeId}"
        status.text = item.visitStatus
        when(item.visitStatus){
            "已通过"->{
                status.setTextColor(Color.parseColor("#065F46"))
                status.setBackgroundResource(R.drawable.item_visit_bg1)
            }
            "待审核"->{
                status.setTextColor(Color.parseColor("#92400E"))
                status.setBackgroundResource(R.drawable.item_visit_bg2)

            }
            "驳回"->{
                status.setTextColor(Color.parseColor("#374151"))
                status.setBackgroundResource(R.drawable.item_visit_bg3)

            }
        }
        val textView = holder.getView<TextView>(R.id.visit_request_parking)
        val imageView = holder.getView<ImageView>(R.id.visit_item_car)
        if(item.requestParking){
            imageView.setImageResource(R.drawable.visit_item_car_yes)
            textView.text = "已申请访客车位：A区-12号"
            textView.setTextColor(Color.parseColor("#1E88E5"))
        }else{
            imageView.setImageResource(R.drawable.visit_item_car_no)
            textView.text = "未申请访客车位"
            textView.setTextColor(Color.parseColor("#9CA3AF"))
        }


    }
}